<div class="form-group">
    <label class="col-sm-2 control-label">[title]</label>
    <div class="col-sm-7">
        <input class="form-control" type="hidden" name="[name]" value="{$info['[name]']|default=''}"/>
            <img onclick="alertImage(this)" src="{$info['[name]']|default='__STATIC__/default.png'}" style="width:80px;height:80px;"/>
        <button type="button" class="layui-btn [hidden]" id="[name]">
            <i class="layui-icon">&#xe67c;</i>上传图片
        </button>
    </div>
</div>

<script>
layui.use('upload', function(){
    var upload = layui.upload;

    var nameDom = "[name]";
    //执行实例
    upload.render({
        elem: "#"+nameDom //绑定元素
        ,url: "{:url('File/store')}" //上传接口
        ,accept:"images"
        ,exts:"png|jpg|jpeg"
        ,done: function(res){
            //上传完毕回调
            $('#'+nameDom).parent().find('input[name*='+nameDom+']').val(res.data.saveName);
            $('#'+nameDom).parent().find('img').attr('src', res.data.saveName);
            // $('#'+nameDom).parent().find('a').text("点击预览");
        }
    });
});

function alertImage(e){
    layer.open({
        type: 1,
        title: false,
        closeBtn: 0,
        maxWidth:700,
        maxHeight:700,
        shadeClose: true,
        skin: '',
        content: '<img style="max-width: 1000px; max-height: 1000px" src="' + e.src + '" />'
    });
}

</script>